﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
using System.Configuration;

namespace Scheduler
{
    public static class Scheduler
    {
        private static Timer _timer;
        private static DateTime _lastRun = DateTime.Now;


        static Scheduler() 
        {
            _timer = new Timer(10 * 60 * 1000);
            _timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
        }

       
        private static void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            AppSettingsReader configurationAppSettings = new AppSettingsReader();
            (string)(configurationAppSettings.GetValue("UtilitiesFolder", typeof(string)));

            // ignore the time, just compare the date
            if (_lastRun.Date < DateTime.Now.Date)
            {
                // stop the timer while we are running the cleanup task
                _timer.Stop();
                //
                // do cleanup stuff
                //
                _lastRun = DateTime.Now;
                _timer.Start();
            }
        }

    }
}
